#include "pch.h"

UniformViewMatrixUpdateCallback::UniformViewMatrixUpdateCallback(osg::Camera * camera) :
	mCamera(camera)
	, m_bFirstTime(true)
{

}

void UniformViewMatrixUpdateCallback::operator()(osg::Uniform* uniform, osg::NodeVisitor* nv)
{
	osg::Matrix matrixV = mCamera->getViewMatrix();
	uniform->set(matrixV);
	//OSG_NOTICE << "ViewMatrixUpdateCallback:" << matrixV(0,0) << std::endl;
	//if (m_bFirstTime)
	//{
	//	double near, far, value1, value2;
	//	mCamera->getProjectionMatrixAsPerspective(value1, value2, near, far);
	//	OSG_NOTICE << "Near:" << near << ",\t" << "Far:" << far << std::endl;
	//	osg::Vec4f v1 = osg::Vec4f(near, far, value1, value2);
	//	uniform->set(v1);
	//	m_bFirstTime = false;
	//}
}